"""
@author: Sergiy Tsymbalyuk
"""

import logging

from pylons.i18n import lazy_ugettext as _
from repoze.what.plugins.pylonshq import ControllerProtector
from repoze.what.predicates import has_permission

from chowa.lib.site.crud import FlatCrudController
from chowa.model.auth import User
from chowa.model.abstract import Person

log = logging.getLogger(__name__)

@ControllerProtector(has_permission('site.administer.security'))
class UsersController(FlatCrudController):
    __model__ = User
    __columns__ = ['person', 'username', 'last_login', 'last_activity', 'is_disabled']
    __join__ = [Person]
    __order__ = ['surname', 'name', 'patronymic']
    __edit_columns__ = ['username', 'person', '_password', 'repeat_password', 'bad_password', 'groups', 'is_disabled']
    __bool_values__ = {'is_disabled': (_('blocked'), '', '')}
    __main_heading__ = _('Security')